
#import "Content.h"


@implementation Content
-(instancetype)initWith:(NSDictionary *)dict{
    self = [super init];
    if (self != nil) {
//        NSLog(@"%@",dict);
        NSDictionary *user = [dict objectForKey:@"User"];
        [self setOwnName:[user objectForKey:@"Name"]];
        [self setOwnAvatar:[user objectForKey:@"Avatar"]];
        [self setOwnGender:[[user objectForKey:@"Gender"]integerValue]];
        
        NSDictionary *data = [dict objectForKey:@"Data"];
        [self setID:[data objectForKey:@"ID"]];
        [self setOwnID:data[@"OwnID"]];
        [self setLikeNum:[[data objectForKey:@"LikeNum"]integerValue]];
        [self setRemarks:[data objectForKey:@"Remarks"]];
        [self setCommentNum:[[data objectForKey:@"CommentNum"]integerValue]];
        [self setEditDate:[[data objectForKey:@"EditDate"]integerValue]];
        [self setPublishDate:[[data objectForKey:@"PublishDate"]integerValue]];
        [self setType:data[@"Type"]];
        
        TextContent *text = [[TextContent alloc]init];
        [text setTitle:[data objectForKey:@"Name"]];
        [text setDetail:[data objectForKey:@"Detail"]];
        text.tags = [[NSMutableArray alloc]init];
        for (NSString* tag in data[@"Tag"]) {
            [text.tags addObject:tag];
        }
        [text setIsPublic:[data objectForKey:@"Public"]];
        [self setText:text];
        
        NSDictionary *d4 = data[@"Album"];
        AlbumContent *album = [[AlbumContent alloc]init];
        [album setTitle:d4[@"Title"]];
        [album setTime:[d4[@"Time"] integerValue]];
        [album setLocation:d4[@"Location"]];
        album.images = [[NSMutableArray alloc]init];
        for (NSDictionary* d5 in d4[@"Images"]) {
            Image *image = [[Image alloc]init];
            [image setNative:d5[@"Native"]];
            [image setUrl:d5[@"Url"]];
            [image setThumb:d5[@"Thumb"]];
            NSDictionary* d6=d5[@"File"];
            image.file = [[File alloc]init];
            [image.file setFilepath:d6[@"File"]];
            [image.file setTitle:d6[@"Title"]];
            [image.file setSize:[d6[@"Size"]integerValue]];
            [image.file setTime:[d6[@"Time"]integerValue]];
            [image.file setCount:[d6[@"Count"]integerValue]];
            [image.file setType:d6[@"Type"]];
        }
        [self setAlbum:album];
    }
    return self;
}
@end
@implementation TextContent
@end
@implementation File
@end
@implementation Image
@end
@implementation AlbumContent
@end
@implementation ContentFileReq
@end

